<?php
/**
 * CreateTime: 2023/12/5 16:16
 * User:LinQ
 */

namespace App\Http\Controllers\User;

use App\Http\Controllers\BasicInterfaceController;
use App\Http\Controllers\Controller;
use App\Http\Requests\System\ListRequest;
use App\Http\Requests\User\ManageUserRequest;
use App\Http\Service\User\ManageUserService;

class ManageUserController extends Controller implements BasicInterfaceController
{

    public function getList()
    {
        $request = request()->only('page','page_size','filters','desc');
        (new ListRequest())->check($request);
        (new ManageUserService())->getList($request);
    }

    public function getSelect()
    {
        (new ManageUserService())->getSelect();
    }

    public function getSelectHasPage()
    {
        $request = request()->only('page','page_size','filters','desc');
        (new ListRequest())->check($request);
        (new ManageUserService())->getSelectHasPage($request);
    }

    public function getInfo($id)
    {
        (new ManageUserService())->getInfo($id);
    }

    public function create()
    {
        $request = request()->only(
            'name',
            'com_id',
            'department_id',
            'account',
            'password',
            'email',
            'phone',
            'leader_id'
        );
        (new ManageUserRequest())->check($request);
        (new ManageUserService())->create($request);
    }

    public function fakeDelete($id)
    {
        (new ManageUserService())->fakeDelete($id);
    }

    public function delete()
    {

    }

    public function update($id)
    {
        $request = request()->only(
            'name',
            "account",
            "password",
            "phone",
            "email",
            "leader_id"
        );
        $request['user_id'] = $id;
        (new ManageUserRequest())->scene('update')->check($request);
        (new ManageUserService())->update($request);
    }

    public function fakeDeleteByIds($ids)
    {

    }

    public function getCurrentUser(){
        (new ManageUserService())->getCurrentUserInfo();
    }

}
